package red.internal.core.message;

/**
 * @author Jin Zheng
 * @since 2020-05-16
 */
public class HandshakeMessage extends Message
{
	private String token;

	public HandshakeMessage()
	{
	}

	public static HandshakeMessage create(String token)
	{
		HandshakeMessage message = Message.create(Protocol.HANDSHAKE);
		message.setToken(token);
		return message;
	}

	protected HandshakeMessage toResponse(boolean success, String message)
	{
		HandshakeMessage response = this.createResponse(message);
		response.setCode(success ? Code.SUCCESS : Code.HANDSHAKE);
		return response;
	}

	public String getToken()
	{
		return token;
	}

	public void setToken(String token)
	{
		this.token = token;
	}
}
